def water_of_jug(x,y,z):
    if z==0: return True
    if x==0: return x==z
    if y==0: return y==z

    def GCD(a, b):
        min_val = min(a,b)
        while min_val:
            if a % min_val == 0 and b % min_val == 0: return min_val
            min_val -= 1
        return 1

    gcd = GCD(x,y)
    return z % gcd == 0